package com.ruoyi.manager.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.manager.domain.ArvinDatabaseClassification;
import com.ruoyi.manager.service.IArvinDatabaseClassificationService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 项目分类Controller
 * 
 * @author arvin
 * @date 2025-04-01
 */
@RestController
@RequestMapping("/project/classification")
public class ArvinDatabaseClassificationController extends BaseController
{
    @Autowired
    private IArvinDatabaseClassificationService arvinDatabaseClassificationService;

    /**
     * 查询项目分类列表
     */
    @PreAuthorize("@ss.hasPermi('project:classification:list')")
    @GetMapping("/list")
    public TableDataInfo list(ArvinDatabaseClassification arvinDatabaseClassification)
    {
        startPage();
        List<ArvinDatabaseClassification> list = arvinDatabaseClassificationService.selectArvinDatabaseClassificationList(arvinDatabaseClassification);
        return getDataTable(list);
    }

    /**
     * 查询所有项目分类列表（不分页）
     */
    @GetMapping("/listAll")
    public AjaxResult listAll(ArvinDatabaseClassification arvinDatabaseClassification)
    {
        List<ArvinDatabaseClassification> list = arvinDatabaseClassificationService.selectArvinDatabaseClassificationList(arvinDatabaseClassification);
        return success(list);
    }

    /**
     * 导出项目分类列表
     */
    @PreAuthorize("@ss.hasPermi('project:classification:export')")
    @Log(title = "项目分类", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ArvinDatabaseClassification arvinDatabaseClassification)
    {
        List<ArvinDatabaseClassification> list = arvinDatabaseClassificationService.selectArvinDatabaseClassificationList(arvinDatabaseClassification);
        ExcelUtil<ArvinDatabaseClassification> util = new ExcelUtil<ArvinDatabaseClassification>(ArvinDatabaseClassification.class);
        util.exportExcel(response, list, "项目分类数据");
    }

    /**
     * 获取项目分类详细信息
     */
    @PreAuthorize("@ss.hasPermi('project:classification:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(arvinDatabaseClassificationService.selectArvinDatabaseClassificationById(id));
    }

    /**
     * 新增项目分类
     */
    @PreAuthorize("@ss.hasPermi('project:classification:add')")
    @Log(title = "项目分类", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ArvinDatabaseClassification arvinDatabaseClassification)
    {
        return toAjax(arvinDatabaseClassificationService.insertArvinDatabaseClassification(arvinDatabaseClassification));
    }

    /**
     * 修改项目分类
     */
    @PreAuthorize("@ss.hasPermi('project:classification:edit')")
    @Log(title = "项目分类", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ArvinDatabaseClassification arvinDatabaseClassification)
    {
        return toAjax(arvinDatabaseClassificationService.updateArvinDatabaseClassification(arvinDatabaseClassification));
    }

    /**
     * 删除项目分类
     */
    @PreAuthorize("@ss.hasPermi('project:classification:remove')")
    @Log(title = "项目分类", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(arvinDatabaseClassificationService.deleteArvinDatabaseClassificationByIds(ids));
    }
}
